﻿Imports System.Data.OleDb

Public Class addcar
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Button_Click(sender As Object, e As EventArgs) Handles Button.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("CarsConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into Table1(CarName,[Year],EngineSize,BHP,Origin,Description,Pictures) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tb_CarName.Text)
        cmd.Parameters.AddWithValue("@f2", tb_Year.Text)
        cmd.Parameters.AddWithValue("@f3", tb_EngineSize.Text)
        cmd.Parameters.AddWithValue("@f4", tb_BHP.Text)
        cmd.Parameters.AddWithValue("@f5", tb_Origin.Text)
        cmd.Parameters.AddWithValue("@f6", tb_Description.Text)
        cmd.Parameters.AddWithValue("@f7", tb_Pictures.Text)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("confirmation.aspx")


    End Sub

End Class

